% TEST_ID: LANG-EXPAND-0108
% CATEGORY: language/string
% 测试 string 的字串提取

function test_string_extractBetween()
str = "The quick brown fox dsf";
newStr = extractBetween(str,"quick "," fox");
result = "brown";
assert_istrue(newStr, result);

str = ["The quick brown fox jumps";"over the lazy dog"];
newStr = extractBetween(str,["quick ";"the "],[" fox";" dog"]);
result = ["brown"
    "lazy"];
assert_istrue(newStr, result);

str = "Edgar Allen Poe";
newStr = extractBetween(str,7,11);
result = "Allen";
assert_istrue(newStr, result);

str = ["Edgar Allen Poe";"Louisa May Alcott"];
newStr = extractBetween(str,[7;8],[11;10]);
result = ["Allen"
    "May"];
assert_istrue(newStr, result);

str1 = "small|medium|large";
newStr = extractBetween(str1,6,13,'Boundaries','exclusive');
result = "medium";
assert_istrue(newStr, result);

str2 = "The quick brown fox jumps over the lazy dog";
newStr = extractBetween(str2," brown","jumps",'Boundaries','inclusive');
result = " brown fox jumps";
assert_istrue(newStr, result);

chr = 'mushrooms, peppers, and onions';
newChr = extractBetween(chr,12,18);
result = {'peppers'};
assert_istrue(newChr{1}, result{1});

end

function assert_istrue(x, y)
    assert(x == y);
end